/**
 * @description 获取几何信息
 * @param {string} elName 元素名称
 * @param {boolean} isCustomComp 是否是自定义组件
 * @param {any} target 当前页面this
 */
export const getElementRect = (elName, isCustomComp = false, target) => {
  return new Promise((resolve, reject) => {
    const query = isCustomComp ? wx.createSelectorQuery().in(target) : wx.createSelectorQuery()
    query
      .select(elName)
      .boundingClientRect((rect) => {
        resolve(rect)
      })
      .exec()
  })
}

export const wxLogin = () => {
  return new Promise((resolve) => {
    wx.login({
      timeout: 10000,
      success: (result) => {
        resolve([undefined, result.code])
      },
      fail: (res) => {
        resolve([res, null])
      }
    })
  })
}
